<template>
  <Card shadow>
    <applied-list ref="appliedList" @resize-table-height="resizeTableHeight"/>
  </Card>
</template>
<script>
import AppliedList from '_c/applied-list/applied-list'
import { on, off } from '@/libs/tools'
export default {
  name: 'applied_form_mgmt',
  // 在实例中使用 components 属性注册需要用到的组件
  components: {
    // 使用 key: value 的形式注册 value 组件，并命名为 key
    'applied-list': AppliedList
  },
  data () {
    return {
      firstEnter: false
    }
  },
  methods: {
    resizeSubComponents () {
      this.$children[0].$el.children[0].style.minHeight = this.$parent.$el.clientHeight - 36 + 'px'
      this.$refs.appliedList.table.height = this.$el.clientHeight - 235
    },
    resizeTableHeight (height) {
      this.$refs.appliedList.table.height -= height
    }
  },
  created () {
    this.firstEnter = true
  },
  mounted () {
    this.$nextTick(() => {
      // document.querySelector('.content-wrapper.ivu-layout-content').style.overflowY = 'scroll'
      this.resizeSubComponents()
      on(window, 'resize', this.resizeSubComponents)
    })
  },
  activated () {
    if (!this.firstEnter) {
      this.resizeSubComponents()
      on(window, 'resize', this.resizeSubComponents)
    }
  },
  deactivated () {
    // document.querySelector('.content-wrapper.ivu-layout-content').style.overflowY = 'auto'
    off(window, 'resize', this.resizeSubComponents)
  },
  beforeDestroy () {
    // document.querySelector('.content-wrapper.ivu-layout-content').style.overflowY = 'auto'
    off(window, 'resize', this.resizeSubComponents)
  }
}
</script>
